﻿using System;
using Windows.UI.Xaml.Controls;

namespace Looptribe.WinRT.Toolkit
{
    public class NavigationService : INavigationService
    {
        private readonly Frame _frame;
        private readonly string _initialNavigationState;

        public NavigationService(Frame frame)
        {
            _frame = frame;
            _initialNavigationState = _frame.GetNavigationState();
        }

        public void ClearHistory()
        {
            _frame.SetNavigationState(_initialNavigationState);
        }

        public void GoBack()
        {
            _frame.GoBack();
        }

        public void GoForward()
        {
            _frame.GoForward();
        }

        public bool Navigate<T>(object parameter = null)
        {
            return _frame.Navigate(typeof (T), parameter);
        }

        public bool Navigate(Type type, object parameter = null)
        {
            return _frame.Navigate(type, parameter);
        }
    }
}
